package com.lujianfei.redpacketstat.database

import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.lujianfei.redpacketstat.App
import com.lujianfei.redpacketstat.database.bean.RedPacketEntity
import com.lujianfei.redpacketstat.database.bean.UserEntity
import com.lujianfei.redpacketstat.database.dao.RedPacketDao
import com.lujianfei.redpacketstat.database.dao.UserDao


@Database(entities = [UserEntity::class,RedPacketEntity::class], version = 1)
abstract class AppDatabase : RoomDatabase() {

    abstract fun userDao(): UserDao
    abstract fun redpacketDao(): RedPacketDao

    companion object {
        val instance = Single.sin
    }

    private object Single {
        val sin: AppDatabase = Room.databaseBuilder(
            App.instance,
            AppDatabase::class.java,
            "redpacket_stat.db"
        )
            .build()
    }
}